#define F_CPU 8000000UL
#include<avr/io.h>
#include<util/delay.h>
#include<compat/deprecated.h>

void SPI_masterinit(void)
{
	/* Set MOSI and SCK output, all others input */
	DDRB = (1<<DDB3)|(1<<DDB5);
	/* Enable SPI, Master, set clock rate fck/16 */
	SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}

void SPI_master_transmit(unsigned char cdata)
{
	/* Start transmission */
	SPDR=cdata;
	/* Wait for transmission complete */
	while(!(SPSR & (1<<SPIF)));
}

int main(void)
{
	unsigned char numero_para_envio;
  	SPI_masterinit();

	numero_para_envio = 0x00;
	while(1)
	{ 
		SPI_master_transmit(numero_para_envio);
		if(numero_para_envio< 128)
			numero_para_envio++;
		_delay_ms(1000);
	}
	
	return 0;
}
